﻿<%@ Page Language="C#" MasterPageFile="~/MasterPageSERIX.Master" AutoEventWireup="true"
    CodeBehind="Login.aspx.cs" Inherits="SERIX.Login" Title="SERIX - Login" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">

    
    <asp:Login ID="Login1" runat="server" CssClass="Login" TextBoxStyle-CssClass="Textbox"
        OnAuthenticate="Login1_Authenticate" DestinationPageUrl="~/Logged1.aspx" FailureText="A tentativa de logon não teve êxito. Tente novamente."
        PasswordRequiredErrorMessage="Senha é requerida.">
        <TextBoxStyle CssClass="Textbox"></TextBoxStyle>
        <LayoutTemplate>
            <div id="login_div">
                <div id="login_titulo">
                    <p> Login </p>
                </div>
                <div id="login_usuario">
                    Usuário&nbsp;
                </div>
                <div id="login_text_usuario">
                    <asp:TextBox ID="UserName" CssClass="Textbox" Width="150px" runat="server"></asp:TextBox>&nbsp;
                </div>
                <div id="login_senha">
                    Senha&nbsp;&nbsp;
                </div>
                <div id="login_text_senha">
                    <asp:TextBox ID="Password" CssClass="Textbox" Width="150px" runat="server" TextMode="Password"></asp:TextBox>&nbsp;
                </div>
                <div id="login_button">
                    <asp:ImageButton ID="LoginButton" AlternateText="Login" CommandName="Login" 
                        runat="server" ImageUrl="~/imagens/login/bt35jxt_0.gif" />
                </div>
                <div id="login_erro">
                    <asp:Literal ID="FailureText" runat="server"></asp:Literal></div>
            </div>
        </LayoutTemplate>
    </asp:Login>

    <script type="text/javascript">
        $(document).ready(function IniciarEventos() {
            carregaLogin();
            $('[id$=UserName]').focus();
        });

        var prm = Sys.WebForms.PageRequestManager.getInstance();
        prm.add_endRequest(function() {
            carregaLogin();
        })

        function carregaLogin() {


            $('[id$=LoginButton]').attr("disabled", "disabled");

            $('.Login .Textbox').focus(function() {
                $(this).attr('class', 'Hover');
            });
            $('.Login .Textbox').blur(function() {
                $(this).attr('class', 'Textbox');
            });
            
            $('[id$=UserName]').keyup(habilitarLogin);
            $('[id$=Password]').keyup(habilitarLogin);
            $('[id$=UserName]').focus(habilitarLogin);
            $('[id$=Password]').focus(habilitarLogin);

            $('[id$=LoginButton]').mouseenter(loginBtnEnter);
            $('[id$=LoginButton]').mouseleave(loginBtnLeave);
            $('[id$=LoginButton]').mousedown(loginBtnDown);

            habilitarLogin();
            $.preloadImages("/imagens/login/bt35jxt_0.gif", "/imagens/login/bt35jxt_1.gif", "/imagens/login/bt35jxt_2.gif", "/imagens/wait.png");

        }

        jQuery.preloadImages = function() {
            for (var i = 0; i < arguments.length; i++) {
                jQuery("<img>").attr("src", arguments[i]);
            }
        }

        function loginBtnEnter() {
            $('[id$=LoginButton]').removeAttr("src");
            $('[id$=LoginButton]').attr("src", "/imagens/login/bt35jxt_1.gif");
        }

        function loginBtnLeave() {
            $('[id$=LoginButton]').removeAttr("src");
            $('[id$=LoginButton]').attr("src", "/imagens/login/bt35jxt_0.gif");
        }

        function loginBtnDown() {
            $('[id$=LoginButton]').removeAttr("src");
            $('[id$=LoginButton]').attr("src", "/imagens/login/bt35jxt_2.gif");
        }

        function habilitarLogin() {
            var login = $('[id$=UserName]').val();
            var pass = $('[id$=Password]').val();
            if (login != '' && pass != '')
                $('[id$=LoginButton]').removeAttr("disabled");
            else
                $('[id$=LoginButton]').attr("disabled", "disabled");
        };
    </script>

</asp:Content>
